<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: seal
  Date: 2016/3/26
  Time: 11:04
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>

    <title>我发布过的</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" type="text/css" href="/static/css/bootstrap.min.css"/>
    <link rel="stylesheet" type="text/css" href="/static/css/mircblog.css"/>
</head>
<body>
<!-- Fixed navbar -->
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
    <div class="container">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse"
                    data-target=".navbar-collapse">
                <span class="sr-only">Toggle navigation</span> <span
                    class="icon-bar"></span> <span class="icon-bar"></span> <span
                    class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#">微调查</a>
        </div>
        <div class="navbar-collapse collapse">
            <ul class="nav navbar-nav">
                <li><a href="/other/index.do">首页</a>
                </li>
                <li class="active" ><a href="/other/subject/mine.do">我发布过的</a>
                </li>
                <li><a href="/other/subject/love.do">我支持过的</a>
                </li>
                <li><a href="/other/subject/reply.do">我回复过的</a>
                </li>
                <li><a href="#about">关于我们</a>
                </li>
            </ul>
            <ul class="nav navbar-nav navbar-right">
                <c:if test="${empty sessionScope.token }">
                    <li><a href="/other/token/login.do">登录</a>
                    </li>
                    <li><a href="/other/token/register.do">注册</a>
                    </li>
                </c:if>
                <c:if test="${not empty sessionScope.token }">
                    <li><a href="">欢迎,${sessionScope.token.nickName }</a>
                    </li>
                    <li><a href="/other/token/logout.do">注销</a>
                    </li>
                </c:if>
            </ul>
        </div>
        <!--/.nav-collapse -->
    </div>
</div>
<div class="container">

        <div class="navbar navbar-default navbar-fixed-bottom">
            <form action="send.do" class="blog-send-form" method="post">

                <div class="alert alert-info" role="alert">
                    你还可以输入<span id="zishu">200</span>个字。
                </div>

                <div class="input-group">
                    <input id="inputContent" name="content" type="text" class="form-control">
      <span class="input-group-btn">
        <a id="send-bt" class="btn  btn-default">发表</a>
      </span>
                </div>
            </form>
        </div>


    <div class="panel panel-primary">
        <div class="panel-heading">
            <h3 class="panel-title">我发布过的</h3>
        </div>
        <div class="panel-body">
            <div class="row">
                <c:forEach items="${pagination.result }" var="subject">
                    <div class="col-4 col-md-4">
                        <h2>${subject.token.nickName }</h2>

                        <p class="blog-post-date">发表于 ${subject.createTime }</p>

                        <p>${subject.content }</p>

                        <p>
                            <a class="btn btn-default" href="#" role="button"><span
                                    class="glyphicon glyphicon-comment"></span>回复</a>
                            <a class="btn btn-default" href="javascript:zhiChi('${subject.id }')" role="button"><span
                                    class="glyphicon glyphicon-thumbs-up"></span><span >${subject.voteCount }</span>个赞</a>
                        </p>
                    </div>
                    <!--/span-->
                </c:forEach>
            </div><!--/row-->
        </div>
        <div class="panel-footer">共发布了${pagination.total}话题。分${pagination.totalPaginationNumber}页,当前是第${pagination.index}页</div>

    </div>
    <nav>
        <ul class="pager">
            <c:if test="${not pagination.firstPagination}">
            <li><a href="/other/subject/mine.do">首页</a></li>
            <li><a href="/other/subject/mine.do">上页</a></li>
            </c:if>
            <c:if test="${not pagination.lastPagination}">
            <li><a href="/other/subject/mine.do">下页</a></li>
            <li><a href="/other/subject/mine.do">尾页</a></li>
            </c:if>
        </ul>
    </nav>




</div>
</body>
<script type="text/javascript" src="/static/jquery.min.js"></script>
<script type="text/javascript" src="/static/bootstrap.min.js"></script>
<script type="application/javascript">
    $(function(){
        $('#inputContent').keyup(function(){
           var zishu=200-$(this).val().length;
            if(zishu>=0){
                $('#zishu').html(zishu);
            }else{
                $(this).val($(this).val().substring(0,200));
            }

        });
        $('#send-bt').click(function(){
            $.post("/other/subject/send.do",{content:$('#inputContent').val()},function(data){
                if(data.state){

                    location.reload(true);

                }else{
                    alert(data.msg);
                }
            });
        });

    });
    function zhiChi(id){
        $.post("/other/vote/vote.do",{subjectId:id},function(data){
           if(data.state){
               alert(data.msg);
               //$('#a'+id).html( +$('#a'+id).html()+1);
               location.reload(true);

           }else{
               alert(data.msg);
           }
        });
    }
</script>
</html>
